package com.bwie.goods.controller;

import com.bwie.common.domain.Vehicle;
import com.bwie.common.result.Result;
import com.bwie.goods.service.VehicleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/Vehicle")
public class VehicleController {
    @Autowired
    VehicleService vehicleService;

    /**
     * 车辆列表
     * @return
     */
    @PostMapping("/list")
    public Result<List<Vehicle>> list(){
        Result<List<Vehicle>> list=vehicleService.list();
        return list;
    }

    /**
     * 车辆添加
     * @param vehicle
     * @return
     */
    @PostMapping("/vehicleAdd")
    public Result vehicleAdd(@RequestBody Vehicle vehicle){
        Result result=vehicleService.vehicleAdd(vehicle);
        return result;
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @PostMapping("/del/{id}")
    public Result del(@PathVariable Integer id){
        Result result=vehicleService.del(id);
        return result;
    }

    /**
     * 修改
     * @param id
     * @return
     */
    @PostMapping("/update/{id}")
    public Result<Vehicle> update(@PathVariable Integer id){
        Result<Vehicle> result=vehicleService.update(id);
        return result;
    }
}
